<?php
namespace app\common\validate;

/**
 * 验证器：文章
 * @package app\common\validate
 * @author jwj <jwjbjg@gmail.com>
 * @copyright jwj
 */
class Article extends Validate
{
    // 验证规则
    protected $rule = [
        'id'          => ['require'],
        'category_id' => ['require'],
        'title'       => ['require', 'max' => 64],
        'content'     => ['require', 'max' => 65535],
        'status'      => ['require', 'between' => '0,1'],
    ];

    // 字段信息
    protected $field = [
        'id'          => 'ID',
        'category_id' => 'ID',
        'title'       => '标题',
        'content'     => '内容',
        'status'      => '状态',
    ];

    /**
     * 场景：添加
     * @return $this
     */
    public function sceneAdd()
    {
        return $this->remove('id', true);
    }

    /**
     * 场景：编辑
     * @return $this
     */
    public function sceneEdit(){
        return $this;
    }
}